<template>
    <div class="rightBodyContent">
      <div class="rightBodyContent-in">
        <div class="mb-10">
          <div class="toplineBox">
            <div class="toplineBox-left">
            <el-select placeholder="学年" v-model="formData.semester_id" size="small"
                    class="w-140 mr-10">
            <el-option :label="item.year" :value="item.id" v-for="(item, index) in yearList"
                    :key="index"></el-option>
            </el-select>
            <el-select placeholder="周" v-model="formData.week" size="small"
                        class="w-140 mr-10">
                <el-option :label="item.name" :value="item.id" v-for="(item, index) in weekList"
                        :key="index"></el-option>
            </el-select>
              <el-button type="primary" size="small" @click="searchFn('search')" class="ml-10"><i
                class="el-icon-search"></i>搜索
              </el-button>
            </div>
            <p class="numberline toplineBox-right">总{{ page.total }}条</p>
          </div>
        </div>
        <!--本体列表，数据 -->
        <div class="table-body">
          <div class="table-body-box">
            <el-table
              ref="multipleTable"
              :data="arryList"
              :stripe="tableStyle.tableStripe"
              :border="tableStyle.tableBorder"
              tooltip-effect="dark"
              style="width: 100%"
              header-cell-class-name="table-text-c"
              cell-class-name="table-text-c"
            >
              <el-table-column
                prop="name"
                width="200px"
                label="家长名称">
                <template slot-scope="scope">
                  {{ scope.row.parents.name || '' }}
                </template>
              </el-table-column>
              <el-table-column
                prop="month"
                width="200px"
                label="孩子名称">
                <template slot-scope="scope">
                  {{ scope.row.student_ids[0].name || '' }}
                </template>
              </el-table-column>
              <el-table-column
                prop="month"
                width="200px"
                label="所在班级">
                <template slot-scope="scope">
                  {{ scope.row.student_ids[0].classes.class_name || '' }}
                </template>
              </el-table-column>
              <el-table-column
                prop="content"
                label="反馈内容">
              </el-table-column>
              <!-- <el-table-column
                prop="month"
                label="位置">
                <template slot-scope="scope">
                  {{ scope.row.book ? scope.row.book.position : '' }}
                </template>
              </el-table-column>
              <el-table-column
                prop="update_time"
                label="报废时间">
              </el-table-column> -->
            </el-table>
          </div>
        </div>
        <!--工具条 分页-->
        <el-col :span="24" class="toolbar">
          <el-pagination
            background
            layout="total, prev, pager, next"
            :total="page.total"
            :page-size="page.pagesize"
            @current-change="handleSizeChange">
          </el-pagination>
        </el-col>
      </div>
    </div>
  </template>
  
  <script>
  import {pagination, tableoption} from '@/utils/util.js'
  
import {mapActions} from "vuex";
import {food_feedback_list} from '@/api/admin/food.js'
import {weekList} from '@/utils/util.js'
  import {
    damage_index
  } from "@/api/admin/book"
  
  export default {
    components: {},
    data() {
      return {
        dateList:null,
        pickerOptions1: {
            disabledDate(time) {
            return time.getTime() > Date.now()//  - 8.64e7
            }
        },
        weekList:weekList,
        yearList:[],
        start_time:null,
        end_time:null,
        arryList: [],
        handleSelection: [],
        // 设置table样式
        tableStyle: tableoption,
        // 设置table页面分页所需
        page: {
          pageindex: pagination.pageIndex,
          pagesize: pagination.pageSize,
          total: pagination.total
        },
        name: '',
        formData: {
            p: 0,// 	整型 	必填 	1 	- 	页码0全部
            week: '',// 	整型 	必填 	1 	- 	周
            semester_id: '',// 	整型 	必填 	1 	- 	学期
        },
        
      }
    },
    created() {
      this.dayListFn()
    },
    watch:{
        dateList(val){
            console.log(val)
            if(val){
                let arrDate = val
                this.start_time = arrDate[0]
                this.end_time = arrDate[1]
            }
            
        }
    },
    methods: {    
        ...mapActions(['getSemester']),
        dayListFn() {
            this.getSemester().then(res => {
                console.log(res,'res888888888888888')

                if (!res.code) {
                    //   this.scoolTime = res.vo;
                    //   this.weekNum = res.week;
                    //   this.defultValue = res
                    this.formData.semester_id = res.vo.id
                    this.formData.week = res.week
                    this.InitFn()

                }
            });
            this.$fetch(this.api.setting.semesterIndex, {}).then((response) => {
                for (let i in response.list) {
                if (response.list[i].type === 1) {
                    response.list[i].year = response.list[i].year + ' 下学期'
                } else {
                    response.list[i].year = response.list[i].year + ' 上学期'
                }
                }
                this.yearList = response.list
            }).catch((err) => {
                console.log(err)
            })
        },
      // 初始化
      InitFn() {
        console.log(this.formData,'this.formData-------------------')
        food_feedback_list(this.formData).then(res => {
          console.log('res', res)
          this.arryList = res.list.data
          this.page.total = res.list.total
        })
      },
      handleSelectionChange(val) {
        this.handleSelection = val
      },
      // 分页
      handleSizeChange(val) {
        this.page.pageindex = val
        this.InitFn()
      },
      searchFn() {
        this.page.pageindex = 1
        this.InitFn()
      },
      // 刷新页面
      refreshFn() {
        this.page.pageindex = 1
        this.name = ''
        this.InitFn()
      },
      addStudent(option) {
        this.wagesDetail = JSON.parse(JSON.stringify(option))
        this.detailvisible = true
      },
      detelFn(id, index) {
        let self_ = this
        this.$confirm('删除当条数据信息，是否继续？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          // wagesDel({
          //   id: id
          // }).then(res => {
          //   this.$message.success('删除成功')
          //   this.InitFn()
          // })
        }).catch(() => {
  
        })
      }
    },
    mounted() {
    }
  }
  </script>
  